<%@page import="com.xiaolin.sports.model.CourseInfo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html class="bgfff">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>课程详情</title>
</head>
<body id="kcbDetailBody">
	<jsp:include page="/WEB-INF/page/common/_header.jsp" />
	<div class="banner">
			<img src="${config.imgUrl }${course.courseImg }"/>
		</div>
		<div class="kcbDetail-part1">
			<h1>${course.courseName }</h1>
			<p class="kcbDetail-priceLine">
				价格：<span class="bmf-top-priceWrap">￥<span class="bmf-top-price">${course.currentPrice }</span></span>
				<span class="collection"><i class="fa fa-heart-o"></i> 收藏</span>
			</p>
			<div class="kcbDetail-yh">
				<p>课程城市：<span id="city"></span> </p>
	            <p>上课地址： ${course.currentAddr }</p>
			</div>
		</div>
		<div class="kcbDetail-part2">
			<ul class="clearfix">
				<li class="on">课程详情</li>
			</ul>
		</div>
		<div class="kcbDetail-part3 pb150">
			<div class="kcbDetail-content kcbDetail-content1 ">${desc }</div>
		</div>
		<div class="kcbDetail-bottom">
			<div><a class="gdkc" href="<%=basePath %>/course">更多课程</a></div>
			<div><a class="ljbm" href="<%=basePath %>/course/sign/detail/${course.id}">立即报名</a></div>
		</div>
	<script type="text/javascript">
		$("#city").html(dictDataFormat("city", "${course.city}"));
	</script>
	<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
	<script type="text/javascript">
		collection();
		$(".collection").click(function() {
			if($(".collection").find("i.fa-heart-o").length > 0) {
				add();
			}else{
				cancel();
			}
		});
		function add() {
			$.ajax({
		 		url : basePath + "/collection/add",
		 		type : "post",
		 		data : {
		 			courseId : '${course.id}'
		 		},
		 		dataType : "json",
		 		async : false,
		 		success : function(data) {
		 			if(data.code == "000") {
		 				$(".collection").find("i").removeClass("fa-heart-o").addClass("fa-heart").attr("style","color:red");
		 			}
		 		}, error:function(){
		 			alert("系统异常，请联系管理员");
        		}
		 	});
		}
		function cancel() {
			$.ajax({
		 		url : basePath + "/collection/cancel",
		 		type : "post",
		 		data : {
		 			courseId : '${course.id}'
		 		},
		 		dataType : "json",
		 		async : false,
		 		success : function(data) {
		 			if(data.code == "000") {
		 				$(".collection").find("i").removeClass("fa-heart").addClass("fa-heart-o").attr("style","");
		 			}
		 		}, error:function(){
		 			alert("系统异常，请联系管理员");
        		}
		 	});
		}
		function collection() {
			$.ajax({
		 		url : basePath + "/collection/query",
		 		type : "post",
		 		data : {
		 			courseId : '${course.id}'
		 		},
		 		dataType : "json",
		 		async : false,
		 		success : function(data) {
		 			if(data == 1) {
		 				$(".collection").find("i").removeClass("fa-heart-o").addClass("fa-heart").attr("style","color:red");
		 			}
		 		}, error:function(){
		 			alert("系统异常，请联系管理员");
        		}
		 	});
		}
	</script>
</body>
</html>